home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Browsers, Managers & Extensions / Firefox Backup Extension 6.0.3 / chrome / febe.jar / content / febeVerifyext.js < prev    next >
Text File  |  2008-08-06  |  5KB  |  145 lines

  1. // author: Chuck Baker
  2. // contact: febe@customsoftwareconsult.com
  3. // Version 6.0
  4.  
  5. febeSetMsgs();
  6.  
  7. function febeVerifyExtension(){
  8.     febex = false;
  9.     febeVerifyExtensions();
  10.     if(febex) febeVerifyExtensions();    // Run again to fix
  11.     return true;
  12. }//function febeVerifyExtension(){
  13.  
  14. function febeVerifyExtensions(){
  15.     window.document.title = febeMsg[237];
  16.     // Create pointer to profile directory
  17.     febeProfDir = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
  18.     var extDir = febeProfDir.clone();
  19.     extDir.append("extensions");
  20.     var errCnt = 0;
  21.     var extCnt = 0;
  22.     var entries = extDir.directoryEntries;
  23.     while(entries.hasMoreElements()){
  24.         var entry = entries.getNext();   
  25.         entry.QueryInterface(Ci.nsILocalFile);
  26.         if(!entry.isDirectory()){
  27.             if(febex){
  28.                 if(febeDeleteInvalidExt(entry.path)){
  29.                     var tmp = "<p><b>"+febeMsg[226]+"</b> "+febeMsg[220].replace("%PATH%",entry.path)+"  <b>"+febeMsg[227]+"</b><br></p>";
  30.                     febeprt(tmp);
  31.                     continue;
  32.                 }//if
  33.             }//if
  34.             var tmp = "<p>***";
  35.             tmp += "<b>"+febeMsg[226]+"</b><br>";
  36.             tmp += "<b>"+febeMsg[220].replace("%PATH%",entry.path)+"</b><br>";
  37.             tmp += "***</p>";
  38.             febeprt(tmp,"red",15);    // Not a directory
  39.             errCnt++;
  40.             continue;
  41.         }//if
  42.         var GUID = extDir.clone();
  43.         GUID.append(entry.leafName);
  44.         var entries2 = GUID.directoryEntries;
  45.         if(!entries2.hasMoreElements()){
  46.             if(!entry.isDirectory()){
  47.                 if(febex){
  48.                     if(febeDeleteInvalidExt(entry.path)){
  49.                         var tmp = "<p><b>"+febeMsg[226]+"</b> "+febeMsg[221].replace("%GUID%",GUID.path)+"  <b>"+febeMsg[227]+"</b><br></p>";
  50.                         febeprt(tmp);
  51.                         continue;
  52.                     }//if
  53.                 }//if
  54.                 var tmp = "<p>***";
  55.                 tmp += "<b>"+febeMsg[226]+"</b><br>";
  56.                 tmp += "<b>"+febeMsg[221].replace("%GUID%",GUID.path)+"</b><br>";
  57.                 tmp += "***</p>";
  58.                 febeprt(tmp,"red",15);    // Directory is empty
  59.                 errCnt++;
  60.                 continue;
  61.             }//if
  62.         }//if
  63.         GUID.append("install.rdf");
  64.         if(!GUID.exists()){
  65.             if(febex){
  66.                 if(febeDeleteInvalidExt(entry.path)){
  67.                     var tmp = "<p><b>"+febeMsg[226]+"</b> "+febeMsg[222].replace("%ITEM%",GUID.path)+"  <b>"+febeMsg[227]+"</b><br></p>";
  68.                     febeprt(tmp);
  69.                     continue;
  70.                 }//if
  71.             }//if
  72.             var tmp = "<p>***";
  73.             tmp += "<b>"+febeMsg[226]+"</b><br>";
  74.             tmp += febeMsg[222].replace("%ITEM%",GUID.path)+"<br>";
  75.             tmp += "***</p>";
  76.             febeprt(tmp,"red",15);    // No install.rdf
  77.             errCnt++;
  78.             continue;
  79.         }//if
  80.         
  81.         var thisExt = new febeExtInfo(GUID.parent.leafName);
  82.         //alert(GUID.parent.leafName)
  83.         if(!thisExt) continue;
  84.         var extName = thisExt.name;
  85.         var extVer = febeStripSpaces(thisExt.version);
  86.         var extIsDisabled = thisExt.isDisabled;
  87.         var extIcon = thisExt.iconURL;
  88.         if(extIsDisabled){extIcon = "chrome://febe/skin/disabled.png";}
  89.         var extHome = thisExt.homepageURL;
  90.  
  91.         var eType = thisExt.type;                            // 2=Extension, 4=Theme
  92.         if(eType != 2 && eType != 4){continue;}            // Not an extension or theme ... what is it?
  93.         var tmp = "<img src='"+extIcon+"' ";
  94.         tmp += "style='border: 0px solid ; width: 16px; height: 16px;'/> ";
  95.         tmp += thisExt.guid+" <b>"+extName+"</b>";
  96.         if(extIsDisabled) tmp += " <i>(disabled)</i>";
  97.         tmp += " - OK";
  98.         if(eType == 2){
  99.             febeprt(tmp,"blue");    // Extension
  100.         }//if
  101.         if(eType == 4){
  102.             febeprt(tmp,"green");    // Theme    
  103.         }//if
  104.         extCnt++;
  105.     }//while
  106.     if(errCnt == 0){
  107.         var tmp = febeMsg[223].replace("%CNT%",extCnt);  // All OK
  108.         febeprt(tmp,"purple");
  109.         febeAlert(tmp);
  110.     }else{
  111.         var tmp = "<style>color: red; font-weight: bold; font-size: 20px;</style>";
  112.         tmp += febeMsg[224] + "\n";
  113.         tmp += "<style>color: purple; font-weight: bold; font-size: 15px;</style>"+febeMsg[225];
  114.         febex = febeConfirm(tmp);
  115.         //if(!OK){return false;}
  116.     }//if
  117.     var box = document.getElementById("messages");
  118.     box.contentDocument.close();
  119.     return true;
  120. }//febeVerifyExtensions()
  121.  
  122. function febeDeleteInvalidExt(path){
  123.     var aFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
  124.     if (!aFile) return false;
  125.     aFile.initWithPath(path);
  126.     try{
  127.         aFile.remove(true);
  128.     }catch(e){
  129.         febeAlert(e.toString())
  130.         return false;
  131.     }//try/catch
  132.     return true;    
  133. }//febeDeleteInvalidExt()
  134.  
  135. function febeprt(txt,color,size){
  136.     // Display content in log window
  137.     if(!color) color="black";
  138.     if(!size) size = 12;
  139.     var box = document.getElementById("messages");
  140.     txt = "<span style='font-family: Courier New,Courier,monospace; font-size: "+size+"px; color: "+color+";'>"+txt+"<br></span>"
  141.     box.contentDocument.write(txt);
  142.     var scrollBox = box.contentWindow.document.body;
  143.     scrollBox.scrollTop = scrollBox.scrollHeight - scrollBox.clientHeight
  144.     return true;
  145. }//febeprt()